import axios from "axios";

const scmiBaseUrl= "http://localhost:8082";
const scmiRequest={
    loadScmis(scmi,callBack){
        let url = scmiBaseUrl + "/scmi/list?";
        if(scmi){
            if(scmi.scmiEncode){
                url += "&scmiEncode=" + scmi.scmiEncode;
            }
            if(scmi.scmiName){
                url += "&scmiName=" + scmi.scmiName;
            }
            if(scmi.scmiType){
                url += "&scmiType=" + scmi.scmiType;
            }
        }
        axios.get(url)
            .then(res=>{
                callBack(res.data);
            })
    },
    insertScmi(scmi,callBack){
        let url = scmiBaseUrl + "/scmi/insert";
        axios.post(url,scmi)
            .then(res=>{
                callBack(res.data);
            })
    },
    update(scmi,callBack){
        let url  = scmiBaseUrl + "/scmi/update";
        axios.put(url,scmi)
            .then(res=>{
                callBack(res.data);
            })
    },
    selectById(scmiId,callBack){
        let url = scmiBaseUrl + "/scmi/selectById?scmiId=" + scmiId;
        axios.get(url)
            .then(res=>{
                callBack(res.data);
            })
    },
    delete(scmiId,callBack){
        let url = scmiBaseUrl + "/scmi/delete?scmiId=" + scmiId;
        axios.delete(url)
            .then(res=>{
                callBack(res.data);
            })
    }
}

export default scmiRequest;
